#include<iostream>
#include<unistd.h>
#include<stdlib.h>
#include<sys/wait.h>
#include<sys/types.h>


using namespace std;

int main()
{

    cout << "I'm a process: "<<"PID:"<<getpid()<< " PPID: "<< getpid()<< endl;
    pid_t id = fork();

    char *envp[] = {
        "MY_VAR=HelloWorld",
       "PATH=/bin:/usr/bin",
        NULL 
    };
    
    char *argv[] = {
        "ls",
        "-l",
        "-a",
        NULL
    };
    if(id == 0)
    {
        cout <<"Child PID: "<< getpid() << endl;
        
        execvpe("ls",argv,envp);
        exit(1);
    }
    int ret = waitpid(id,NULL,0);
    if(ret > 0)
    cout << "Father PID: "<<getpid()<< " " <<"Child PID: "<< ret << endl;


    return 0;
}

